package com.china08.yxyapi.repository.db.holiday;

import java.util.List;

import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

public class Hello {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        // ListenableFuture<ResponseEntity<RespModel>> rr = new
        // RestTemplate().getForEntity(
        // "http://localhost:9082" +
        // "/api_yx/comm/teacherofschool/schoolId/522abfb3af444960a1853e7bf98b7bbe",
        // RespModel.class);

        ResponseEntity<List<RespModel>> rateResponse = new RestTemplate().exchange(
                "http://localhost:9082" + "/api_yx/comm/teacherofschool/schoolId/522abfb3af444960a1853e7bf98b7bbe",
                HttpMethod.GET, null, new ParameterizedTypeReference<List<RespModel>>() {
                });
        List<RespModel> rates = rateResponse.getBody();

        for (RespModel re : rates) {
            System.out.println(re.getTeacherNick());
        }

        // System.out.println(rates);
        // System.out.println(list);
    }

    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class RespModel {
        @JsonCreator
        public RespModel(@JsonProperty("teacherId") String teacherId, @JsonProperty("schoolId") String schoolId,
                @JsonProperty("schoolNick") String schoolNick, @JsonProperty("teacherNick") String teacherNick) {
            super();
            this.teacherId = teacherId;
            this.schoolId = schoolId;
            this.schoolNick = schoolNick;
            this.teacherNick = teacherNick;
        }

        private String teacherId;
        private String schoolId;
        private String schoolNick;
        private String teacherNick;

        public String getTeacherId() {
            return teacherId;
        }

        public void setTeacherId(String teacherId) {
            this.teacherId = teacherId;
        }

        public String getSchoolId() {
            return schoolId;
        }

        public void setSchoolId(String schoolId) {
            this.schoolId = schoolId;
        }

        public String getSchoolNick() {
            return schoolNick;
        }

        public void setSchoolNick(String schoolNick) {
            this.schoolNick = schoolNick;
        }

        public String getTeacherNick() {
            return teacherNick;
        }

        public void setTeacherNick(String teacherNick) {
            this.teacherNick = teacherNick;
        }

    }

}
